import pandas as pd
import xlwings as xw
from matplotlib import pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']  # 显示中文

app = xw.App(visible=False)
wb = app.books.open('文件路径')
sheet = wb.sheets[0]

df = sheet.range('A1').options(pd.DataFrame, expand='table').value

figure = plt.figure(figsize=(10,6), dpi=100)  # 创建画布
plt.plot(df['销量'])
sheet.pictures.add(figure, name='销量图', update=True, \
    left=sheet.range('A1').left , top=sheet.range('A1').top)
wb.save()
wb.close()
app.quit()

